<script setup lang="ts">
import { ref } from "vue";
import { formRules } from "./utils/rule";
import { FormProps } from "./utils/types";

const props = withDefaults(defineProps<FormProps>(), {
  formInline: () => ({
    name: "",
    code: "",
    remark: ""
  })
});

const ruleFormRef = ref();
const newFormInline = ref(props.formInline);

function getRef() {
  return ruleFormRef.value;
}

defineExpose({ getRef });
</script>

<template>
  <el-form
    ref="ruleFormRef"
    :model="newFormInline"
    :rules="formRules"
    label-width="82px"
  >
    <el-form-item label="关键词" prop="name">
      <el-input
        v-model="newFormInline.name"
        clearable
        placeholder="请输入关键词"
      />
    </el-form-item>

    <el-form-item label="同义词" prop="code">
      <el-input
        v-model="newFormInline.code"
        clearable
        placeholder="请输入同义词"
      />
    </el-form-item>

    <el-form-item label="关联词">
      <el-input v-model="newFormInline.remark" placeholder="请输入关联词" />
    </el-form-item>
  </el-form>
</template>
